﻿@model COMCMS.Core.ArticleCategory
@{
    ViewBag.title = "编辑文章栏目";
}

<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>@ViewBag.Title</h5>
            <div class="ibox-tools">
            </div>
        </div>
        <div class="ibox-content">
            @using (Html.BeginForm(null, null, FormMethod.Post, new { id = "editArticleKindForm", @class = "form-horizontal m-t" }))
            {
                <div class="form-group">
                    <label class="col-sm-3 control-label">上级栏目：</label>
                    <div class="col-sm-8">
                        <select class="form-control m-b" asp-for="PId">
                            <option value="0">一级栏目</option>
                            @foreach (var m in ViewBag.ListTree)
                            {
                                <option value="@m.Id">@m.KindName</option>
                            }
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">栏目名称：</label>
                    <div class="col-sm-8">
                        <input id="KindName" name="KindName" maxlength="200" type="text" class="form-control" value="@Model.KindName" required aria-required="true" placeholder="填写栏目名称" onblur="aoutoTransform()">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">栏目路径：</label>
                    <div class="col-sm-8">
                        <input id="FilePath" name="FilePath" maxlength="100" type="text" class="form-control" aria-required="true" value="@Model.FilePath" placeholder="填写栏目路径，SEO优化使用，最多支持4级目录，可以输入字母、数字和-">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">副标题：</label>
                    <div class="col-sm-8">
                        <input id="SubTitle" type="text" class="form-control" name="SubTitle" placeholder="栏目副标题，非必填" value="@Model.SubTitle" maxlength="200">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label">Banner图片：</label>
                    <div class="col-sm-8">
                        <div class="input-group">
                            <span class="input-group-btn my-preview">
                                @if (!string.IsNullOrEmpty(Model.BannerImg))
                                {
                                    <img src="@Model.BannerImg" />
                                }
                                else
                                {
                                    <button type="button" class="btn btn-primary"><i class="fa fa-search-plus"></i></button>
                                }
                            </span>
                            <input id="BannerImg" name="BannerImg" maxlength="250" type="text" class="form-control upload-path" placeholder="请选择或上传一个Banner图片" value="@Model.BannerImg">
                            <span class="input-group-addon my-upload-span upload-img"></span>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">排序：</label>
                    <div class="col-sm-8">
                        <input id="Rank" type="number" class="form-control" name="Rank" value="@Model.Rank" maxlength="20" placeholder="越小排得越前" aria-required="true">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">文章列表：</label>
                    <div class="col-sm-8">
                        <label class="checkbox-inline i-checks">
                            <input type="checkbox" value="1" name="IsList" id="IsList" @(Model.IsList == 1 ? "checked" : "")> 文章列表页（勾上则该栏目为文章列表页面。）
                        </label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label">列表文章数量：</label>
                    <div class="col-sm-8">
                        <input id="PageSize" type="number" class="form-control" name="PageSize" value="@Model.PageSize" maxlength="20" placeholder="文章列表页面每页文章显示条数，仅对文章列表页面有效" aria-required="true">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">显示下级栏目文章：</label>
                    <div class="col-sm-8">
                        <label class="checkbox-inline i-checks">
                            <input type="checkbox" value="1" name="IsShowSubDetail" id="IsShowSubDetail" @(Model.IsShowSubDetail == 1 ? "checked" : "")> 显示下级栏目文章（勾选则该栏目列表，显示下级栏目文章。）
                        </label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label">栏目模板：</label>
                    <div class="col-sm-8">
                        <select class="form-control" asp-for="TemplateFile">
                            @foreach (string s in ViewBag.ListTpl)
                            {
                                if (s.ToLower().StartsWith("index"))
                                {
                                    <option value="@s">@s</option>
                                }
                            }
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">文章模板：</label>
                    <div class="col-sm-8">
                        <select class="form-control" asp-for="DetailTemplateFile">
                            @foreach (string s in ViewBag.ListTpl)
                            {
                                if (s.ToLower().StartsWith("detail"))
                                {
                                    <option value="@s">@s</option>
                                }
                            }
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">隐藏栏目：</label>
                    <div class="col-sm-8">
                        <label class="checkbox-inline i-checks">
                            <input type="checkbox" value="1" name="IsHide" id="IsHide" @(Model.IsHide == 1 ? "checked" : "")> 隐藏栏目（栏目在前台不显示）
                        </label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label">栏目关键字：</label>
                    <div class="col-sm-8">
                        <input id="Keyword" type="text" class="form-control" name="Keyword" value="@Model.Keyword" maxlength="250" placeholder="优化搜索引擎搜录" aria-required="true">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">栏目描述：</label>
                    <div class="col-sm-8">
                        <input id="Description" type="text" class="form-control" name="Description" value="@Model.Description" maxlength="250" placeholder="优化搜索引擎搜录" aria-required="true">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">跳转链接：</label>
                    <div class="col-sm-8">
                        <input id="LinkURL" type="text" class="form-control" name="LinkURL" value="@Model.LinkURL" maxlength="200" placeholder="填写则点击该类别自动跳转到该地址，如果填写数字，则跳转到改id的文章详情" aria-required="true">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">栏目介绍：</label>
                    <div class="col-sm-8">
                        <textarea id="KindInfo" name="KindInfo" class="form-control" placeholder="可以输入栏目的详细介绍">@Model.KindInfo</textarea>
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="form-group">
                    <div class="col-sm-4 col-sm-offset-3">
                        <input type="hidden" value="@Model.Id" id="Id" name="Id" />
                        <button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> 提交 </button>
                        <button class="btn btn-default" type="button" onclick="closethisdialog();"><i class="fa fa-close"></i> 取消 </button>
                    </div>
                </div>
            }
        </div>
    </div>


</div>

<script>
    $(function () {
        $(".upload-img").InitUploader({ filesize: "10240", sendurl: "/AdminCP/Upload/DoWebuploaderImage", swf: "/js/webuploader/uploader.swf", filetypes: "gif,jpg,png,bmp", notwater: true });
        DoPost("editArticleKindForm");
        CKEDITOR.replace('KindInfo');
    });
    function aoutoTransform() {
        var title = $("#KindName").val();
        var filePath = $("#FilePath").val();
        var pid = $("#PId").val();
        if (!filePath) {
            $.ajax({
                type: "POST",
                url: "/AdminCP/Server/Hanzi2Pinyin",
                data: { name: title, pid: pid, t: "articlecategory" },
                dataType: "JSON",
                success: function (data) {
                    if (data.status == "success") {
                        if (data.message) {
                            $("#FilePath").val(data.message);
                        }
                    } else {
                        layer.alert(data.message, { icon: 2 });
                    }
                },
                error: function () {
                    layer.alert('执行错误，请联系管理员！', { icon: 2 });
                }
            });
        }
    }
</script>